import { reactive } from "vue";
import { findAgencyApi } from "../api/agency";
import { findTeamsApi } from "../api/teamManage";
import { getDoctorRolesApi } from "../api/doctorManage";
import { getTagsApi } from "../api/Tags";
import { findTagApi } from "../api/tagcontrol";
import { findServicePacksApi } from "../api/servicePacks";
import { findSignsApi } from "../api/signs";


export function useFindData() {
    //机构数据
    const AgencyData = reactive({rows:[],total:0})
    //团队数据
    const TeamData = reactive({rows:[],total:0})
    //医生角色数据
    const DoctorRolesData = reactive({rows:[],total:0})
    //标签数据
    // const TagData = reactive({rows:[],total:0})

    // 标签数据
    const TagsData = reactive({rows:[],total:0})
    // 服务包数据
    const ServicePacksData = reactive({rows:[],total:0})
    // 签约状态数据
    const SignsData = reactive({rows:[],total:0})

    //获取机构方法
    function findAgencyAsync(params){
        findAgencyApi(params)
        .then(res =>{
            if(res.code ==200){
                AgencyData.rows = res.data.rows;
                AgencyData.total = res.data.total
            }
        })
    }
    //查询团队方法
    function findTeamAsync(params) {
        findTeamsApi(params)
            .then(res => {
                if (res.code == 200) {
                    TeamData.rows = res.data.rows;
                    TeamData.total = res.data.total
                }
            })
    }

    //获取医生角色
    function findDoctorRolesAsync(params){
        getDoctorRolesApi({group:'一组'})
        .then(res =>{
            if(res.code == 200){
                DoctorRolesData.rows = res.data.rows;
                DoctorRolesData.total = res.data.total
            }
        })
    }

    //获取标签
    // function findTagsAsync(params) {
    //     getTagsApi(params)
    //         .then(res => {
    //             if (res.code == 200) {
    //                 TagData.rows = res.data.rows;
    //                 TagData.total = res.data.total
    //             }
    //         })
    // }

    //获取标签方法
    function findTagsAsync(params){
        findTagApi(params)
        .then(res =>{
            if(res.code ==200){
                TagsData.rows = res.data.rows;
                TagsData.total = res.data.total
            }
        })
    }

    //获取服务包方法
    function findServicePacksAsync(params){
        findServicePacksApi(params)
        .then(res =>{
            if(res.code ==200){
                ServicePacksData.rows = res.data.rows;
                ServicePacksData.total = res.data.total
            }
        })
    }

     //获取签约方法
    function findSignsAsync(params){
        findSignsApi(params)
        .then(res =>{
            if(res.code ==200){
                SignsData.rows = res.data.rows;
                SignsData.total = res.data.total
            }
        })
    }

    
    return {
        AgencyData, findAgencyAsync,
        TeamData, findTeamAsync,
        DoctorRolesData,findDoctorRolesAsync,
        // TagData, findTagsAsync,
        TagsData,findTagsAsync,
        ServicePacksData,findServicePacksAsync,
        SignsData,findSignsAsync
    }
}